/**
 * 代理模式
 */

// 声明接口
class Subject {}

Subject.prototype.useVpn = () => {}


class RealSubject extends Subject {
  constructor() {
    super()
  }

  useVpn() {
    console.log('使用VPN')
  }

}

class ProxySubject extends Subject {
  constructor() {
    super()
  }

  useVpn() {
    const realSubject = new RealSubject()
    this.readMe()
    realSubject.useVpn()
  }

  readMe() {
    console.log('你正在通过代理使用VPN')
  }

}

class ProxyPattern {
  constructor() {
    this.useVpn = new ProxySubject()
  }
}

const proxyPattern = new ProxyPattern()

proxyPattern.useVpn.useVpn()
